var Reactive = /** @class */ (function () {
    function Reactive(obj) {
        if (typeof obj !== "object")
            throw Error("被代理的对象必须是object类型");
        var _this = this;
        this.proxy = new Proxy(obj, {
            set: function (target, key, value) {
                _this.setEffect(key, target[key], value);
                target[key] = value;
                return true;
            },
            get: function (target, key) {
                _this.getEffect(key, target[key]);
                return target[key];
            },
            deleteProperty: function (target, key) {
                _this.deleteEffect(key);
                delete target[key];
                return true;
            }
        });
    }
    Reactive.prototype.getEffect = function (key, val) {
        console.log(key.toString() + "\u5C5E\u6027\u503C\u4E3A\uFF1A" + val);
    };
    Reactive.prototype.setEffect = function (key, oldVal, newVal) {
        console.log("\u5C5E\u6027" + key.toString() + "\u7531" + oldVal + "\u8BBE\u7F6E\u4E3A" + newVal);
    };
    Reactive.prototype.deleteEffect = function (key) {
        console.log("\u5C5E\u6027" + key.toString() + "\u88AB\u5220\u9664");
    };
    return Reactive;
}());
var obj = {
    a: 1,
    b: "jiji"
};
var reactive = new Reactive(obj);
reactive.proxy.a;
reactive.proxy.b = "ahahah";
delete reactive.proxy.b;
console.log(obj);
